package me.firstapp.service.weixin.transfer.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import me.firstapp.module.weixin.transfer.TransferMember;
import me.firstapp.repository.weixin.transfer.TransferMemberRepository;
import me.firstapp.service.weixin.transfer.TransferMemberService;

@Service
public class TransferMemberServiceImpl implements TransferMemberService {

	@Autowired
	private TransferMemberRepository transferMemberRepository;

	@Override
	public Long findMemberTransferCounts(Long ownMemberId) {
		return transferMemberRepository.findMemberTransferCounts(ownMemberId);
	}

	@Override
	public List<TransferMember> findTransferMembers(Long ownMemberId, Integer status) {
		return transferMemberRepository.findTransferMembers(ownMemberId, status);
	}

	@Override
	public TransferMember findTransferMember(Long memberId, Long ownMemberId) {
		return transferMemberRepository.findTransferMember(memberId, ownMemberId);
	}

	@Override
	public TransferMember executeAdd(Long memberId, Long ownMemberId) {
		TransferMember transferMember = new TransferMember();
		transferMember.setMemberId(memberId);
		transferMember.setOwnMemberId(ownMemberId);
		transferMember.setStatus(TransferMember.STATUS_NORMAL);
		transferMemberRepository.save(transferMember);
		return transferMember;
	}

}
